/*

This CSS file will be included with your plugin, and
available in the app when your plugin is enabled.

If your plugin does not need CSS, delete this file.

*/

/* Base styles for Jupyter notebook */
.jupyter-cell {
    margin: 1em 0;
    padding: 1em;
    border: 1px solid var(--background-modifier-border);
    width: 100%;
    box-sizing: border-box;
}

.cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5em;
}

.cell-type-indicator {
    color: var(--text-muted);
    font-size: 0.8em;
}

/* Code block styling */
.code-cell {
    width: 100%;
    overflow-x: auto;
}

.input-area {
    width: 100%;
    overflow-x: auto;
    position: relative;
}

.code-wrapper {
    display: flex;
    min-width: fit-content;
    background-color: var(--code-background);
    border-radius: 4px;
    position: relative;
}

.jupyter-code-block {
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--code-background);
    border-radius: 4px;
    user-select: text;
    -webkit-user-select: text;
}

.code-content {
    flex: 1;
    overflow-x: auto;
    min-width: 0;
    position: relative;
}

.code-content pre {
    margin: 0;
    padding: 1em;
    min-width: fit-content;
    box-sizing: border-box;
    overflow: visible;
    white-space: pre-wrap;
}

.code-content code {
    white-space: pre-wrap;
    word-wrap: normal;
    display: inline-block;
    min-width: 100%;
    user-select: text !important;
    -webkit-user-select: text !important;
    cursor: text;
    font-family: var(--font-monospace);
    line-height: 1.5;
}

/* Line numbers */
.line-numbers {
    padding: 1em 0.5em;
    border-right: 1px solid var(--background-modifier-border);
    background-color: var(--code-background);
    color: var(--text-muted);
    user-select: none;
    -webkit-user-select: none;
    text-align: right;
    min-width: 2.5em;
    position: sticky;
    left: 0;
    z-index: 1;
    height: 100%;
}

.line-number {
    font-family: var(--font-monospace);
    font-size: 0.85em;
    line-height: 1.5;
    height: 1.5em;
    user-select: none;
    -webkit-user-select: none;
}

/* Output styling */
.output-container {
    position: relative;
    margin-top: 0.5em;
    padding-left: 20px;
    width: 100%;
    background: var(--background-primary);
    border-radius: 4px;
}

.output-cell {
    transition: max-height 0.3s ease-in-out;
    overflow: hidden;
    width: 100%;
    border-left: 2px solid var(--text-accent);
    margin-left: 1em;
    padding-left: 1em;
}

.output-cell.expanded {
    max-height: 100vh; /* Use viewport height instead of explicit pixel value */
}

.output-cell.collapsed {
    max-height: 50px;
}

.output-wrapper {
    display: block;
    width: 100%;
    padding: 0.8em;
    min-width: 0;
    overflow-x: auto;
    background: var(--background-secondary);
    border-radius: 4px;
    margin: 0.5em 0;
}

/* Add scrollbar styling back */
.output-wrapper::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.output-wrapper::-webkit-scrollbar-track {
    background: var(--background-modifier-border);
    border-radius: 4px;
}

.output-wrapper::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

/* Stream output styling */
.stream-output {
    font-family: var(--font-monospace);
    white-space: pre;
    color: var(--text-normal);
    padding: 0.5em;
    background: var(--background-primary);
    border-radius: 4px;
    border-left: 3px solid var(--text-accent);
    overflow-x: auto;
}

.stream-output.stderr {
    border-left-color: var(--text-error);
    background: var(--background-modifier-error);
    color: var(--text-error);
}

/* Plain text output */
.plain-text-output {
    font-family: var(--font-monospace);
    white-space: pre;
    padding: 0.5em;
    background: var(--background-primary);
    border-radius: 4px;
    border-left: 3px solid var(--text-accent);
    overflow-x: auto;
}

/* Error output styling */
.error-output {
    color: var(--text-error);
    padding: 0.5em;
    background: var(--background-modifier-error);
    border-radius: 4px;
    margin: 0.5em 0;
}

.error-header {
    font-weight: bold;
    margin-bottom: 0.5em;
    font-family: var(--font-monospace);
}

.error-traceback {
    margin: 0;
    padding: 0.8em;
    background: var(--background-primary);
    border-radius: 4px;
    font-family: var(--font-monospace);
    white-space: pre;
    color: var(--text-error);
    border-left: 3px solid var(--text-error);
    overflow-x: auto;
}

/* HTML output */
.html-output {
    background: var(--background-primary);
    padding: 0.8em;
    border-radius: 4px;
    margin: 0.5em 0;
    overflow-x: auto;
    max-width: 100%;
}

/* Table styling in outputs */
.html-output table {
    border-collapse: collapse;
    margin: 1em 0;
    width: max-content;
    min-width: 100%;
}

.html-output th,
.html-output td {
    border: 1px solid var(--background-modifier-border);
    padding: 0.5em;
    text-align: left;
}

.html-output th {
    background: var(--background-secondary);
    font-weight: bold;
}

.html-output tr:nth-child(even) {
    background: var(--background-secondary);
}

/* Image output styling */
.image-container {
    display: flex;
    justify-content: center;
    margin: 1em 0;
    padding: 1em;
    background: var(--background-primary);
    border-radius: 4px;
}

.output-image {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-placeholder {
    padding: 2em;
    background: var(--background-primary);
    border: 2px dashed var(--text-muted);
    border-radius: 4px;
    color: var(--text-muted);
    text-align: center;
    margin: 1em 0;
    font-style: italic;
}

/* Preview styles */
.jupyter-notebook-preview {
    margin: 1em 0;
    padding: 1em;
    border: 1px solid var(--background-modifier-border);
    border-radius: 4px;
    background: var(--background-primary);
    width: 100%;
    box-sizing: border-box;
}

.notebook-cell {
    margin-bottom: 1em;
    padding: 0.5em;
    background: var(--background-secondary);
    border-radius: 4px;
}

.cell-type {
    color: var(--text-muted);
    font-size: 0.8em;
    margin-bottom: 0.5em;
    text-transform: uppercase;
}

/* Preview-specific styles */
.jupyter-preview-error {
    color: var(--text-error);
    padding: 1em;
    background: var(--background-secondary);
    border-radius: 4px;
    margin: 0.5em 0;
}

.jupyter-notebook-preview .cell-outputs {
    margin-top: 0.5em;
    padding-left: 1em;
    border-left: 2px solid var(--text-accent);
}

.jupyter-notebook-preview .code-cell pre {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.5em;
    background: var(--code-background);
    border-radius: 4px;
}

.jupyter-notebook-preview .markdown-cell {
    width: 100%;
    padding: 0.5em;
}

/* Add these styles for cell editing */
.cell-edit-button {
    padding: 2px 8px;
    border-radius: 4px;
    background-color: var(--interactive-normal);
    color: var(--text-normal);
    cursor: pointer;
    font-size: 0.8em;
}

.cell-edit-button:hover {
    background-color: var(--interactive-hover);
}

.cell-edit-button.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.editor-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.editor-button {
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    background-color: var(--interactive-normal);
    color: var(--text-normal);
    border: 1px solid var(--background-modifier-border);
}

.editor-button:hover {
    background-color: var(--interactive-hover);
}

.save-button {
    background-color: var(--interactive-accent);
    color: var(--text-on-accent);
}

.save-button:hover {
    background-color: var(--interactive-accent-hover);
}

/* Auto-resize textarea styles */
.cell-editor.auto-resize {
    box-sizing: border-box;
    width: 100%;
    min-height: 100px;
    overflow: hidden;
    resize: none;
}

.cell-editor.adjusting {
    height: auto;
}

/* Add a class for content height */
.cell-editor.auto-resize.adjusting {
    height: auto;
    min-height: var(--content-height, 100px);
}

/* Ensure smooth resizing */
.cell-editor {
    transition: none;
}

/* Add these styles for the toggle button */
.output-toggle {
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: 0.5em;
    transition: transform 0.3s ease;
}

.output-toggle:hover {
    color: var(--text-normal);
}

.output-toggle svg {
    width: 16px;
    height: 16px;
}

.output-toggle.collapsed {
    transform: rotate(-90deg);
}
